It's recommended that you read the Introduction before proceeding. After you have a brief understanding of how Clash works, you can start writing your own configuration.
Configuration Files The main configuration file is called config.yaml. By default, Clash reads the configuration files at $HOME/.config/clash. If it doesn't exist, Clash will generate a minimal configuration file at that location.
If you want to place your configurations elsewhere (e.g. /etc/clash), you can use command-line option -d to specify a configuration directory:
shellclash -d . # current directoryclash -d /etc/clashOr, you can use option -f to specify a configuration file:
shellclash -f ./config.yamlclash -f /etc/clash/config.yamlSpecial Syntaxes There are some special syntaxes in Clash configuration files, of which you might want to be aware:
IPv6 Addresses You should wrap IPv6 addresses in square brackets, for example:
txt[aaaa::a8aa:ff:fe09:57d8]DNS Wildcard Domain Matching In some cases, you will need to match against wildcard domains. For example, when you're setting up Clash DNS, you might want to match against all subdomains of localdomain.
Clash do offer support on matching different levels of wildcard domains in the DNS configuration, while the syntaxes defined below:
TIP
Any domain with these characters should be wrapped with single quotes ('). For example, '*.google.com'.
Use an astrisk (*) to match against a single-level wildcard subdomain.
ExpressionMatchesDoes Not Match*.google.comwww.google.comgoogle.com*.bar.google.comfoo.bar.google.combar.google.com*.*.google.comthoughtful.sandbox.google.comone.two.three.google.comUse a plus sign (+) to match against multi-level wildcard subdomains.
ExpressionMatchesDoes Not Match+.google.comwww.google.comwww.google.com+.google.comthoughtful.sandbox.google.comwww.google.com+.google.comone.two.three.google.comwww.google.com